from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.schema import Document

docs = [
    Document(page_content="First document content. " * 50, metadata={"source": "doc1.txt"}),
    Document(page_content="Second document content. " * 50, metadata={"source": "doc2.txt"})
]

splitter = RecursiveCharacterTextSplitter(chunk_size=100, chunk_overlap=20)
chunks = splitter.split_documents(docs)

for c in chunks[:3]:
    print(c.page_content)
    print(c.metadata)